<?php
namespace Library;
use Phalcon\Mvc\User\Plugin;
use Phalcon\Config\Adapter\Ini;
class StateCode extends Plugin
{
    public static  function __callStatic($name,$arg)
    {
        $config=self::getConfig('msg');
        $charat=strpos($name,'_');
        if($charat < 0) {
            return false;
        }else if($charat > 0){
            $param=substr($name,0,$charat);
            $name=substr($name,$charat);
            
        }else{
            $param ='code';
        }
        $msg=$config->$param->$name;
        return $arg && (is_array($arg[0]) || $arg[0]===true)?['code'=>substr($name,1),'status'=>1,'msg'=>$msg,'data'=>is_array($arg[0])?$arg[0]:[]]:['code'=>substr($name,1),'status'=>0,'msg'=>$msg,'data'=>[]] ;
        
    }
        
    public static  function getConfig($file=''){
        if(!$file){
            return false;
        }
        $config=new Ini(APP_PATH.'/config/'.$file.'.ini');
        return $config;
    }
    
   
}

?>